#ifndef _FIG_LIFE_OBJ_H_
#define _FIG_LIFE_OBJ_H_

#include "fig_sfx.h"
#include "ui/ui_manager.h"

class FIGBullet;
class FIGSFXManager;
class FIGSfx;

//this class is to bridge between craft obj and background obj
// mainly it provides HitTest Functions


class FIGLifeObj
{
public:

	

	FIGLifeObj();


									   
	// needs this informations to calculate HITEST functions
	virtual const math::Vec2&	GetPos() = 0;
	virtual const math::Vec2&	GetSize() = 0;
	virtual float				GetRadius() = 0;
	virtual float				GetRotation() = 0;
	virtual ui::UISprite*		GetSprite() = 0;

	virtual void				Tick(float dt);
	virtual bool				HitTest(FIGBullet* pBuulet);
	virtual bool				HitTest(FIGLifeObj* pCraft);
	virtual void				Clear(){};
	

	bool						HitTest(const math::Vec2& Min, 
										const math::Vec2& Max, 
										float DamageAmount);
	virtual bool				HitTest(const math::Vec2& Point);
	bool						HitTestCircle(const math::Vec2& Point);

	bool						IsInSideScreen();
	virtual void				GotDamage(float Amount,FIGBullet* pBullet, bool Force);
		
	virtual void				ReSpawn();
	bool						IsAlive() const { return m_IsAlive; };
	bool						IsHitAble() const  { return m_IsHitAble; };
	bool						IsReadyToFire() const { return m_IsReadyToFire; };
	int							GetScoreForKilling() const { return (int)m_MaxLife; };
	float						GetDamageForColliding() { return m_DamageForColliding; };
	void						ForceKill() { m_IsAlive = false; };
	void						RenderSFX(const math::Vec2& Offset, float Scale);
	virtual bool				IsGroundObject() const { return false; };

protected:

	static bool					HitTest(ui::UISprite* pSprite, 
										const math::Vec2& Point, 
										const math::Vec2& SpritePos,
										const math::Vec2& SpriteSize
										);
	
	virtual void				OnStartDying(){};
	virtual void				OnExplode();
	virtual void				OnShoot(){};

	virtual void				OnDie();
	void						AddSFX(FIGSfx* pSFX);
	
	bool						m_IsAlive; 
	bool						m_ToDie;
	float						m_Life;
	float						m_MaxLife;
	float						m_ExtraLife;
	float						m_GetHitCounter;
	math::Counter				m_ShootCounter;
	bool						m_IsReadyToFire;
	bool						m_IsHitTestCircle;
	FIGSfx::SFX_TYPES			m_ExplodSfx;
	FIGSounds::SOUND_NAMES		m_ExplodSoundSfx;
	float						m_ExplodeSize;
	float						m_DelayDie;
	bool						m_IsHitAble;
	float						m_DamageForColliding;
	float						m_OffsetScale;
	bool						m_SkipExplodeSingle;
	std::vector<FIGSfx*>		m_SFXs;

};

#endif